package com.zzzyh.forumsystemclient.services.impl;

import com.zzzyh.forumsystemclient.dao.MessageMapper;
import com.zzzyh.forumsystemclient.model.Message;
import com.zzzyh.forumsystemclient.services.IMessageSercive;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class MessageSerciveImpl implements IMessageSercive {
    @Autowired
    private MessageMapper messageMapper;
    @Override
    public List<Message> getChatMessages(Long user1, Long user2) {
        log.info("getChatMessages: user1: {}, user2: {}", user1, user2);
        return messageMapper.selectByUser(user1,  user2);
    }

    @Override
    public void addMessage(Message message) {
        messageMapper.insertSelective(message);
    }
}
